package com.hziee.inm.product.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hziee.inm.product.entity.CommoditiesEntity;
import com.hziee.inm.product.service.CommoditiesService;
import com.hziee.common.utils.PageUtils;
import com.hziee.common.utils.R;



/**
 * 
 *
 * @author yb
 * @email yangbin@gmail.com
 * @date 2020-12-12 21:06:40
 */
@RestController
@RequestMapping("product/commodities")
public class CommoditiesController {
    @Autowired
    private CommoditiesService commoditiesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("product:commodities:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = commoditiesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{cId}")
    //@RequiresPermissions("product:commodities:info")
    public R info(@PathVariable("cId") Integer cId){
		CommoditiesEntity commodities = commoditiesService.getById(cId);

        return R.ok().put("commodities", commodities);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:commodities:save")
    public R save(@RequestBody CommoditiesEntity commodities){
		commoditiesService.save(commodities);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("product:commodities:update")
    public R update(@RequestBody CommoditiesEntity commodities){
		commoditiesService.updateById(commodities);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:commodities:delete")
    public R delete(@RequestBody Integer[] cIds){
		commoditiesService.removeByIds(Arrays.asList(cIds));

        return R.ok();
    }

}
